package com.taotao.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.common.pojo.EUDataGridResult;
import com.taotao.common.pojo.TaotaoResult;
import com.taotao.pojo.TbContent;
import com.taotao.service.IContentService;

@Controller
@RequestMapping(value = "/content")
public class ContentController {
	@Autowired
	private IContentService contentService;

	/**
	 * 通过内容分类id查询分类内容信息
	 * 
	 * @param categoryId
	 * @param page
	 * @param rows
	 * @return
	 */
	@RequestMapping("/query/list")
	@ResponseBody
	public EUDataGridResult getContentList(Long categoryId, Integer page,
			Integer rows) {
		EUDataGridResult eugr = this.contentService.getContentList(categoryId,
				page, rows);
		System.out.println(eugr.getTotal());
		return eugr;
	}

	/**
	 * 保存内容信息
	 * 
	 * @param content
	 * @return
	 */
	@RequestMapping(value = "/save")
	@ResponseBody
	public TaotaoResult saveContent(TbContent content) {
		TaotaoResult taotaoResult = this.contentService.saveContent(content);
		System.out.println(taotaoResult);
		if (taotaoResult.getStatus() == 200) {
			return taotaoResult;
		}
		return null;

	}
}
